package com.minimalist.common.entity.basic.vo.notice;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.NoticeEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.entity.basic.vo.file.FileVO;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 11987
 */
@Schema(name = "公告管理实体")
public class NoticeVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "公告ID不能为空", groups = {Update.class})
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "noticeId", description = "公告ID", type = "string")
    private Long noticeId;

    @NotBlank(message = "公告标题不能为空", groups = {Add.class, Update.class})
    @Schema(name = "noticeTitle", description = "公告标题", type = "string")
    private String noticeTitle;

    @NotNull(message = "公告类型不能为空", groups = {Add.class, Update.class})
    @SchemaEnum(implementation = NoticeEnum.NoticeType.class)
    @Schema(name = "noticeType", description = "公告类型", type = "string")
    private Integer noticeType;

    @NotBlank(message = "公告内容不能为空", groups = {Add.class, Update.class})
    @Schema(name = "noticeContent", description = "公告内容", type = "string")
    private String noticeContent;

    @Schema(name = "noticePicFileId", description = "公告封面图文件ID，多张 , 分割", type = "string")
    private String noticePicFileId;

    @Schema(name = "noticePicFile", description = "公告封面图文件信息，返回数据时填充该数据", type = "array")
    private List<FileVO> noticePicFile;

    @Schema(name = "noticeTop", description = "是否置顶", type = "string")
    private Boolean noticeTop;

    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @Schema(name = "noticeTimeInterval", description = "延期发布时间", type = "string")
    private LocalDateTime noticeTimeInterval;

    @Schema(name = "noticeSort", description = "排序值", type = "string")
    private Integer noticeSort;

    @Schema(name = "noticeOutChain", description = "是否外链", type = "string")
    private Boolean noticeOutChain;

    @Schema(name = "noticeLink", description = "外部链接", type = "string")
    private String noticeLink;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "publishDeptId", description = "发布部门ID", type = "string")
    private Long publishDeptId;

    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "发布人不能为空", groups = {Add.class, Update.class})
    @Schema(name = "publishAuthorId", description = "发布人ID", type = "string")
    private Long publishAuthorId;

    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @Schema(name = "publishTime", description = "发布时间", type = "string")
    private LocalDateTime publishTime;

    @NotNull(message = "公告状态不能为空", groups = {Add.class, Update.class})
    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "status", description = "公告状态", type = "string")
    private Byte status;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "createId", description = "创建人ID", type = "string")
    private Long createId;

    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @Schema(name = "createTime", description = "创建时间", type = "string")
    private LocalDateTime createTime;

    public Long getNoticeId() {
        return noticeId;
    }

    public void setNoticeId(Long noticeId) {
        this.noticeId = noticeId;
    }

    public String getNoticeTitle() {
        return noticeTitle;
    }

    public void setNoticeTitle(String noticeTitle) {
        this.noticeTitle = noticeTitle;
    }

    public Integer getNoticeType() {
        return noticeType;
    }

    public void setNoticeType(Integer noticeType) {
        this.noticeType = noticeType;
    }

    public String getNoticeContent() {
        return noticeContent;
    }

    public void setNoticeContent(String noticeContent) {
        this.noticeContent = noticeContent;
    }

    public String getNoticePicFileId() {
        return noticePicFileId;
    }

    public void setNoticePicFileId(String noticePicFileId) {
        this.noticePicFileId = noticePicFileId;
    }

    public List<FileVO> getNoticePicFile() {
        return noticePicFile;
    }

    public void setNoticePicFile(List<FileVO> noticePicFile) {
        this.noticePicFile = noticePicFile;
    }

    public Boolean getNoticeTop() {
        return noticeTop;
    }

    public void setNoticeTop(Boolean noticeTop) {
        this.noticeTop = noticeTop;
    }

    public LocalDateTime getNoticeTimeInterval() {
        return noticeTimeInterval;
    }

    public void setNoticeTimeInterval(LocalDateTime noticeTimeInterval) {
        this.noticeTimeInterval = noticeTimeInterval;
    }

    public Integer getNoticeSort() {
        return noticeSort;
    }

    public void setNoticeSort(Integer noticeSort) {
        this.noticeSort = noticeSort;
    }

    public Boolean getNoticeOutChain() {
        return noticeOutChain;
    }

    public void setNoticeOutChain(Boolean noticeOutChain) {
        this.noticeOutChain = noticeOutChain;
    }

    public String getNoticeLink() {
        return noticeLink;
    }

    public void setNoticeLink(String noticeLink) {
        this.noticeLink = noticeLink;
    }

    public Long getPublishDeptId() {
        return publishDeptId;
    }

    public void setPublishDeptId(Long publishDeptId) {
        this.publishDeptId = publishDeptId;
    }

    public Long getPublishAuthorId() {
        return publishAuthorId;
    }

    public void setPublishAuthorId(Long publishAuthorId) {
        this.publishAuthorId = publishAuthorId;
    }

    public LocalDateTime getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(LocalDateTime publishTime) {
        this.publishTime = publishTime;
    }

    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    public Long getCreateId() {
        return createId;
    }

    public void setCreateId(Long createId) {
        this.createId = createId;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NoticeVO noticeVO = (NoticeVO) o;
        return java.util.Objects.equals(noticeId, noticeVO.noticeId) &&
               java.util.Objects.equals(noticeTitle, noticeVO.noticeTitle) &&
               java.util.Objects.equals(noticeType, noticeVO.noticeType) &&
               java.util.Objects.equals(noticeContent, noticeVO.noticeContent) &&
               java.util.Objects.equals(noticePicFileId, noticeVO.noticePicFileId) &&
               java.util.Objects.equals(noticePicFile, noticeVO.noticePicFile) &&
               java.util.Objects.equals(noticeTop, noticeVO.noticeTop) &&
               java.util.Objects.equals(noticeTimeInterval, noticeVO.noticeTimeInterval) &&
               java.util.Objects.equals(noticeSort, noticeVO.noticeSort) &&
               java.util.Objects.equals(noticeOutChain, noticeVO.noticeOutChain) &&
               java.util.Objects.equals(noticeLink, noticeVO.noticeLink) &&
               java.util.Objects.equals(publishDeptId, noticeVO.publishDeptId) &&
               java.util.Objects.equals(publishAuthorId, noticeVO.publishAuthorId) &&
               java.util.Objects.equals(publishTime, noticeVO.publishTime) &&
               java.util.Objects.equals(status, noticeVO.status) &&
               java.util.Objects.equals(createId, noticeVO.createId) &&
               java.util.Objects.equals(createTime, noticeVO.createTime);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(noticeId, noticeTitle, noticeType, noticeContent, noticePicFileId, noticePicFile, noticeTop, noticeTimeInterval, noticeSort, noticeOutChain, noticeLink, publishDeptId, publishAuthorId, publishTime, status, createId, createTime);
    }

    @Override
    public String toString() {
        return "NoticeVO{" +
               "noticeId=" + noticeId +
               ", noticeTitle='" + noticeTitle + '\'' +
               ", noticeType=" + noticeType +
               ", noticeContent='" + noticeContent + '\'' +
               ", noticePicFileId='" + noticePicFileId + '\'' +
               ", noticePicFile=" + noticePicFile +
               ", noticeTop=" + noticeTop +
               ", noticeTimeInterval=" + noticeTimeInterval +
               ", noticeSort=" + noticeSort +
               ", noticeOutChain=" + noticeOutChain +
               ", noticeLink='" + noticeLink + '\'' +
               ", publishDeptId=" + publishDeptId +
               ", publishAuthorId=" + publishAuthorId +
               ", publishTime=" + publishTime +
               ", status=" + status +
               ", createId=" + createId +
               ", createTime=" + createTime +
               '}';
    }

}
